home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3006 / 3006.xpi / chrome / dwhelper.jar / content / pick-processor.xul < prev    next >
Extensible Markup Language  |  2010-01-15  |  5KB  |  171 lines

  1. <?xml version="1.0"?> 
  2. <!-- *****************************************************************************
  3.  *            Copyright (c) 2006-2009 Michel Gutierrez. All Rights Reserved.
  4.  ****************************************************************************** -->
  5. <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
  6.  
  7. <!DOCTYPE dialog SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
  8.  
  9. <dialog id="dwhelper-pick-processor"
  10.         title="&title.pick-processor;"
  11.         flex="1"
  12.         onload="onLoad()"
  13.         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  14.         xmlns:html="http://www.w3.org/1999/xhtml"
  15.         buttonlabelextra2="&label.quickkeys.change;"
  16.         ondialogextra2="configureQuickKeys()"
  17.         buttons="cancel,extra2">
  18.         
  19.     <html:style>
  20. #vbox {
  21.     overflow: auto;
  22.     height: 300px;
  23.     width: 460px;
  24. }
  25. groupbox {
  26.   margin: 5px;
  27.   border: 1px solid ThreeDShadow;
  28.   -moz-border-radius: 5px;
  29.   padding: 5px;
  30. }
  31. caption {
  32.   margin: 0px 6px 2px 6px;
  33.   padding: 0px 3px;
  34.   background-color: -moz-Dialog;
  35. }
  36. description {
  37.   width: 200px;
  38. }
  39. button.action {
  40.   width: 200px;
  41. }
  42. .quickkey {
  43.     font-style: italic;
  44. }
  45. .processor {
  46.     margin-bottom: 8px;
  47. }
  48.     </html:style>
  49.  
  50.     <script><![CDATA[
  51. var Util=Components.classes["@downloadhelper.net/util-service;1"]
  52.     .getService(Components.interfaces.dhIUtilService);
  53.  
  54. function onLoad() {
  55.     var processors=window.arguments[0].processors;
  56.     buildContent(processors);
  57. }
  58.  
  59. function buildContent(processors) {
  60.     var keymap={};
  61.     var prefService=Components.classes["@mozilla.org/preferences-service;1"]
  62.                                        .getService(Components.interfaces.nsIPrefService);
  63.     this.pref=prefService.getBranch("dwhelper.");
  64.     var keymapStr="0:download,2:convert-choice,3:quick-download";
  65.     try {
  66.         keymapStr=this.pref.getCharPref("processor-keymap");
  67.     } catch(e) {}
  68.     var p1=keymapStr.split(",");
  69.     for(var i in p1) {
  70.         var p2=p1[i].split(":");
  71.         if(p2.length==2)
  72.             keymap[parseInt(p2[0])]=p2[1];
  73.     }
  74.     
  75.     var vbox=document.getElementById("vbox");
  76.     while(vbox.firstChild)
  77.         vbox.removeChild(vbox.firstChild);
  78.     var providers=[];
  79.     for(var i in processors) {
  80.         var processor=processors[i].processor;
  81.         if(providers.indexOf(processor.provider)<0)
  82.             providers.push(processor.provider);
  83.     }
  84.     for(var j in providers) {
  85.         var provider=providers[j];
  86.         var groupbox=document.createElement("groupbox");
  87.         vbox.appendChild(groupbox);
  88.         var caption=document.createElement("caption");
  89.         caption.setAttribute("label",Util.getFText("caption.provider-services",[provider],1));
  90.         groupbox.appendChild(caption);
  91.         for(var i in processors) {
  92.             var processor=processors[i].processor;
  93.             if(processor.provider==provider) {
  94.                 var box=document.createElement("hbox");
  95.                 box.setAttribute("class","processor");
  96.                 groupbox.appendChild(box);
  97.                 var vbox1=document.createElement("vbox");
  98.                 box.appendChild(vbox1);
  99.                 var button=document.createElement("button");
  100.                 vbox1.appendChild(button);
  101.                 button.setAttribute("label",processor.title);
  102.                 button.setAttribute("class","action");
  103.                 button.setAttribute("oncommand","select('"+processor.name+"')");
  104.                 if(processors[i].canHandle==false)
  105.                     button.setAttribute("disabled","true");
  106.                 var spacer=document.createElement("spacer");
  107.                 spacer.setAttribute("flex","1");
  108.                 vbox1.appendChild(spacer);
  109.  
  110.                 var vbox2=document.createElement("vbox");
  111.                 box.appendChild(vbox2);
  112.                 
  113.                 var key=-1;
  114.                 for(var k in keymap) {
  115.                     if(keymap[k]==processor.name) {
  116.                         key=k;
  117.                         break;
  118.                     }
  119.                 }
  120.                 
  121.                 var keyStr=Util.getText("processor.quickkey.nokey");
  122.                 if(key!=-1) {
  123.                     var kp=[];
  124.                     for(var k=0; k<4; k++) {
  125.                         if((1<<k)&key)
  126.                             kp.push(Util.getText("processor.quickkey.key"+k));
  127.                     }
  128.                     kp.push(Util.getText("processor.quickkey.click"));
  129.                     keyStr=kp.join("+");
  130.                 }
  131.                 
  132.                 var description1=document.createElement("description");
  133.                 vbox2.appendChild(description1);
  134.                 description1.setAttribute("value",keyStr);
  135.                 description1.setAttribute("class","quickkey");
  136.                 
  137.                 
  138.                 var description=document.createElement("description");
  139.                 vbox2.appendChild(description);
  140.                 var descText=document.createTextNode(processor.description);
  141.                 description.appendChild(descText);                        
  142.             }
  143.         }
  144.     }
  145. }
  146.  
  147. function select(procName) {
  148.     window.arguments[0].processor=procName;
  149.     window.close();
  150. }
  151.  
  152. function configureQuickKeys() {
  153.     var params = {};       
  154.     window.openDialog("chrome://dwhelper/content/config-processor-keys.xul", "",
  155.         "chrome, dialog, modal, resizable=no", params).focus();
  156.     if(params.ok) {
  157.         var processors=window.arguments[0].processors;
  158.         buildContent(processors);
  159.     }    
  160. }
  161.  
  162. ]]>
  163.     </script>
  164.  
  165.  
  166.     <vbox id="vbox" flex="1">
  167.             
  168.     </vbox>
  169.  
  170. </dialog>
  171.